<?php
  require(dirname(__FILE__)."/../RequestMethod.php");
  require(dirname(__FILE__)."/../model/ClassManageModel.php");
  class ResolveController extends RequestMethod{
      private $ClassManageModel = null;

      /**
      *构造函数，实例化对象
      */
      public function __construct($urlArr){
          $this->ClassManageModel = new ClassManageModel();
          parent::__construct($urlArr);
      }
      /**
      *GET请求
      */
      public function doGet(){
        $action = $_GET['action'];
          switch ($action) {
				  case 'list':
				  $pagenum = intval($_GET['p']);
				  $pageSize = 5; //每页显示数
                  // $total = $this->ClassManageModel->findClassList(null,' count(*) ');
				  // $totalPage = ceil($total[0]['count(*)']/$pageSize); //总页数
				  // $startPage = $pagenum*$pageSize;
				  
				  $result = $this->ClassManageModel->findClassList2(null);
                  break;
          }
		  echo json_encode($result);
		  // print_r($result);
		  // print_r($total);
      }
      /**
      *POST请求
      */
      public function doPost(){
        $action = $_GET['action'];
          switch ($action) {
              case 'addClass':
				 $classarr['SchoolID'] = $_POST['sch_id'];
				 $classarr['ClassNo'] = $_POST['class_id'];
				 $classarr['SessionYear'] = $_POST['year'];
				 // $classarr['SessionYear'] = $_POST['number'];
				 $result = $this->ClassManageModel->addClass($classarr);
				  break;
              case 'list':
			     // $result=$this->StudentModel->findUserList(null);
               echo "sadasaadsasadass";                
				break;   
				case 'editClass':
				  $arr['ClassNo'] = $_POST['ClassNo'];
				  $arr['ClassName'] = $_POST['ClassName'];
				  $where['ClassID'] = $_POST['ClassID'];
		          $result=$this->ClassManageModel->updateClass($arr,$where);
              	break; 
				case 'deleClass':
				$arr = explode('#',$_POST['check']);
				array_shift($arr);
				foreach($arr as $val){
					$where['ClassID']=$val;
					$result=$this->ClassManageModel->deleteClass($where);
				}
				break;
				 
          }
        echo json_encode($result);
      }
  }
?>
